<?php
    //debug($json_data);
    $cur = $json_data['currency'];
    $tl_pay = $json_data['opening_bal_raw'] + $json_data['tl_inerest_raw'];
?>
<div style="margin-bottom: 15px;">
    <table class="table" style="width:auto;">
        <tr><td>Loan Amount (pv)</td><td><span id="loan_amt"><?php echo $cur." ".$json_data['opening_bal']?></span></td></tr>
        <tr><td>Inerest Rate (rate)</td><td><span id="int_rate"><?php echo $json_data['interest_ratio']?></span></td></tr>
        <tr><td>Total # of Period (Nper)</td><td><span id="tl_period"><?php echo $json_data['duration_in_month']?></span></td></tr>
        <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
        <tr><td>Payment per Period</td><td><span id="pay_per_period"><?php echo $cur." ".$json_data['monthly_inst']?></span></td></tr>
        <tr><td>Total Interest Paid</td><td><span id="tl_int_paid"><?php echo $cur." ".$json_data['tl_inerest']?></span></td></tr>
        <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
        <tr><td>Total Payment</td><td><span id="tl_payment"><?php echo $cur." ".$tl_pay ?></span></td></tr>
    </table>
</div>

<table class="table" id="repayment_detail_flex">
    <thead>
    <tr>
        <th>Period</th>
        <th>Payment Amount</th>
        <th>Interest </th>
        <th>Principal</th>
        <th>Balance</th>
    </tr>
    </thead>
    <tbody>
    <?php
        if(isset($json_data['data'])){
            $data = $json_data['data'];
            foreach($data as $row){
            ?>
                <tr>
                    <td><?php echo $row['period']?></td>
                    <td><?php echo $row['payment_amount']?></td>
                    <td><?php echo $row['inerest']?></td>
                    <td><?php echo $row['principal']?></td>
                    <td><?php echo $row['balance']?></td>
                </tr>
            <?php
            }
        }
    ?>
    </tbody>
</table>


